package com.day06_Collection_test;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @ClassName: ArrayList_demo
 * @Author: 豆豆在睡觉
 * @Create 2024/3/8-20:47
 * @Version 1.0
 */
public class ArrayList_demo {
    public static void main(String[] args) {
        ArrayList<Student> arrayList = new ArrayList<Student>();
        Student d1 = new Student("zw", 12);
        Student d2 = new Student("zwx,", 23);
        Student d3 = new Student("zz", 13);
        arrayList.add(d1);
        arrayList.add(d2);
        arrayList.add(d3);

        for (int i = 0; i <arrayList.size() ; i++) {
            System.out.println(arrayList.get(i).getName());
        }
        System.out.println("----");
        Iterator<Student> it = arrayList.listIterator();

        while (it.hasNext()) {
            Student s = it.next();
            System.out.println(s.getName());
        }
        System.out.println("----");
        for(Student s: arrayList) {
            System.out.println(s.getName());
        }
    }
}
